package com.shopcz.mx.shopcar.manager;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.shopcz.dao.ShopcarDao;
import com.shopcz.pojo.User;
import com.shopcz.pojo.shopCar;

public class AddToCar extends HttpServlet {


	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		this.doPost(request, response);
	}

	
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		
		int goodid = Integer.valueOf(request.getParameter("goodid"));
		int goodnum = Integer.valueOf(request.getParameter("goodnum"));
		User user = (User)request.getSession().getAttribute("user_login");
		shopCar car = new shopCar();
		car.setGoodsId(goodid);
		car.setShopNum(goodnum);
		car.setUserIdbuy(user.getUserId());
		car.setShopStatus(1);
		ShopcarDao carDao = new ShopcarDao();
		if(carDao.save(car)){
			response.sendRedirect("carInfoServlet");
		}
		
	}

}
